package org.example.device.controller;

import lombok.RequiredArgsConstructor;
import org.example.base.entity.Request;
import org.example.base.entity.Result;
import org.example.base.entity.group.Update;
import org.example.device.entity.req.DeviceReq;
import org.example.device.entity.resp.DeviceResp;
import org.example.device.service.DeviceAppService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;

@RestController
@RequestMapping("/info")
@RequiredArgsConstructor
public class DeviceInfoController {
    private final DeviceAppService deviceAppService;
    @GetMapping("/queryDevice")
    public Result<DeviceResp> queryDevice(@RequestParam String id, @RequestParam String groupId) {
        return deviceAppService.queryDevice(id, groupId);
    }

    @PostMapping("/validateWithGroup")
    public Result<?> validateWithGroup(@RequestBody @Validated(Update.class) Request<DeviceReq> request) {
        return Result.OK();
    }

    @PostMapping("/validateWithNoGroup")
    public Result<?> validateWithNoGroup(@RequestBody @Validated Request<DeviceReq> request) {
        return Result.OK();
    }
}
